import { createPinia } from 'pinia'

import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import { useAppStore } from './modules/app'
import { useUserStore } from './modules/user'
import { useMenuInfoStore } from './modules/menuInfo'
import { menuInfoSubStore } from './modules/menuInfoSub'
import { faultSubListStore } from './modules/faultSubList'
import { paramsDataStore } from './modules/paramsData'

// const modulesFiles = import.meta.globEager('./modules/*.js')

// const modules = Object.keys(modulesFiles).reduce((modules, modulePath) => {
//   const moduleName = modulePath.replace(/^\.\/(.*)\.\w+$/, '$1')
//   const value = modulesFiles[modulePath]
//   modules[moduleName] = value.default
//   return modules
// }, {})

// const pinia = createPinia({
//   modules,
// })

const pinia = createPinia()
pinia.use(piniaPluginPersistedstate);
export default pinia
export {
    useAppStore,
    useUserStore,
    useMenuInfoStore,
    menuInfoSubStore,
    faultSubListStore,
    paramsDataStore
}